#include "apue.h"
#include <pthread.h>

pthread_t ntid;

void printThread(const char* s);
void *ThreadFunc(void* arg);

int main(void)
{
    int err;    //表示进程创建的错误代码

    err = pthread_create(&ntid,NULL,ThreadFunc,NULL);
    if(err!=0)
    {
        err_exit(err,"Have Some Error in Create Thread");
    }
    printThread("In Main Thread");
    sleep(1);   //等待进程结束
    exit(0);     
}

void printThread(const char* s)
{
    pid_t pid;  // 当前进程ID
    pthread_t tid;  //当前线程ID

    pid = getpid();
    tid = pthread_self();
    printf("%s pid is %lu tid is %lu (0x%lx)\n",s,(unsigned long)pid,(unsigned long)tid,(unsigned long)tid);
}

void *ThreadFunc(void* arg)
{
    printThread("new Thread...");
    return (void(*))0;
}